package com.ruoyi.project.er.controller;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.er.domain.PaeaErErrorPointRel;
import com.ruoyi.project.er.service.IPaeaErErrorPointRelService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import java.util.Arrays;

import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 督办风险点关系表Controller
 *
 * @author XQ.XU
 * @date 2020-03-25
 */
@Controller
@RequestMapping("/er/paeaErErrorPointRel")
public class PaeaErErrorPointRelController extends BaseController
{
    private String prefix = "er/paeaErErrorPointRel";

    @Autowired
    private IPaeaErErrorPointRelService paeaErErrorPointRelService;

    @RequiresPermissions("er:paeaErErrorPointRel:view")
    @GetMapping()
    public String PaeaErErrorPointRel()
    {
        return prefix + "/paeaErErrorPointRel";
    }

    /**
     * 查询督办风险点关系表列表
     */
    @RequiresPermissions("er:paeaErErrorPointRel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PaeaErErrorPointRel paeaErErrorPointRel)
    {
        startPage();
        List<PaeaErErrorPointRel> list = paeaErErrorPointRelService.list(new QueryWrapper<>(paeaErErrorPointRel));
        return getDataTable(list);
    }

    /**
     * 导出督办风险点关系表列表
     */
    @RequiresPermissions("er:paeaErErrorPointRel:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PaeaErErrorPointRel paeaErErrorPointRel)
    {
        List<PaeaErErrorPointRel> list = paeaErErrorPointRelService.list(new QueryWrapper<>(paeaErErrorPointRel));
        ExcelUtil<PaeaErErrorPointRel> util = new ExcelUtil<PaeaErErrorPointRel>(PaeaErErrorPointRel.class);
        return util.exportExcel(list, "PaeaErErrorPointRel");
    }

    /**
     * 新增督办风险点关系表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存督办风险点关系表
     */
    @RequiresPermissions("er:paeaErErrorPointRel:add")
    @Log(title = "督办风险点关系表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PaeaErErrorPointRel paeaErErrorPointRel)
    {
        return toAjax(paeaErErrorPointRelService.saveOrUpdate(paeaErErrorPointRel));
    }

    /**
     * 修改督办风险点关系表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        PaeaErErrorPointRel paeaErErrorPointRel = paeaErErrorPointRelService.getById(id);
        mmap.put("paeaErErrorPointRel", paeaErErrorPointRel);
        return prefix + "/edit";
    }

    /**
     * 修改保存督办风险点关系表
     */
    @RequiresPermissions("er:paeaErErrorPointRel:edit")
    @Log(title = "督办风险点关系表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PaeaErErrorPointRel paeaErErrorPointRel)
    {
        return toAjax(paeaErErrorPointRelService.saveOrUpdate(paeaErErrorPointRel));
    }

    /**
     * 删除督办风险点关系表
     */
    @RequiresPermissions("er:paeaErErrorPointRel:remove")
    @Log(title = "督办风险点关系表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(paeaErErrorPointRelService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
